package com.ellecity06.cwhiskymall.adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.ellecity06.common.base.BaseAdapter
import com.ellecity06.common.ktx.loadByUser
import com.ellecity06.cwhiskymall.bean.response.MemberInviteResponse
import com.ellecity06.cwhiskymall.databinding.ItemMemerInviterBinding

/**
 * @author ellecity06
 * @time 2024/11/5 11:13
 * @des
 */
class MemberInviteListAdapter :
    BaseAdapter<MemberInviteResponse.Member, ItemMemerInviterBinding>() {
    override fun inflateBinding(
        layoutInflater: LayoutInflater,
        parent: ViewGroup,
        viewType: Int
    ): ItemMemerInviterBinding {
        return ItemMemerInviterBinding.inflate(layoutInflater, parent, false)
    }

    override fun convert(
        binding: ItemMemerInviterBinding,
        position: Int,
        item: MemberInviteResponse.Member
    ) {
        binding.ivAvatar.loadByUser(context, item.pic, 100F)
        binding.tvPhone.text = item.phone
        binding.tvCreateTime.text = item.createTime
        if (item.level == 1) {
            // vip会员已经消费
            binding.tvStatus.visibility = View.GONE
            binding.ivStatusVip.visibility = View.VISIBLE
        } else {
            // vip会员已经消费
            binding.tvStatus.visibility = View.VISIBLE
            binding.ivStatusVip.visibility = View.GONE
        }
    }
}